//
//  TTRecyclingNavigationViewController.m
//  TaoTuo
//
//  Created by apple on 2020/9/18.
//  Copyright © 2020 刘广. All rights reserved.
//

#import "TTRecyclingNavigationViewController.h"
#import "TTRecyclingHomeRightNavbarViewManager.h"
#import "LLListView.h"
#import "TTNotifyViewController.h"

@interface TTRecyclingNavigationViewController ()

@end

@implementation TTRecyclingNavigationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupRightBarButtonItem];
    
}

/// 回收帮助
- (void)dianputhreedotAction
{
    CGRect rect = CGRectMake(SCREEN_WIDTH - 150, StatusBarAndNavBar_Height + 6, 130, 44);
    [LLListView showWithFrame:rect Images:@[@"wenhao_1"] Titles:@[@"回收帮助"] MenuType:ListViewMenuType_ScaleBasedTopRight ClickItem:^(NSInteger index, NSString *title) {
        TTNotifyViewController *notifyVC = [[TTNotifyViewController alloc] initWithPageType:NotifyPageTypeWithHelp];
        [self pushViewController:notifyVC animated:YES];
    } triangleViewSpaceRight:70];
}

// 设置导航栏右边bar
- (void)setupRightBarButtonItem
{
    @weakify(self)
    _segment = [[LLSegmentView alloc] initWithFrame:CGRectMake(kScreenWidth - 105, 7, 90, 30) items:@[[UIImage imageNamed:@"dianputhreedot"], [UIImage imageNamed:@"dianpuquan"]] selectItemBlock:^(NSInteger index, UIButton *selectItemButton) {
        @strongify(self)
        if (index == 0) {
            if ([TTRecyclingHomeRightNavbarViewManager sharedManager].rightBarViewBlock) {
                [TTRecyclingHomeRightNavbarViewManager sharedManager].rightBarViewBlock(index);
            } else {
                [self dianputhreedotAction];
            }
        } else if (index == 1) {
            if (self.viewControllers.count == 1) {
                [self dismissViewControllerAnimated:YES completion:nil];
            } else {
                [self popToRootViewControllerAnimated:YES];
            }
        }
    }];
    _segment.layer.cornerRadius = 15;
    _segment.layer.borderColor = UIColorHex(EEEEEE).CGColor;
    _segment.layer.borderWidth = 0.5;
    [_segment setFont:[UIFont systemFontOfSize:14]];
    [_segment setSelectFont:[UIFont systemFontOfSize:16]];
    [_segment setTitleColor:[UIColor blackColor]];
    [_segment setSelectTitleColor:[UIColor cyanColor]];
    
    [self.navigationBar addSubview:_segment];
}


@end
